for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
const {MongoClient} = require('mongodb');
MongoClient.connect('mongodb://localhost:27017/JokesApp', (err, db) => {
if (err){
return console.log('failed to connect to mongodb server. ', err);
console.log
}
console.log('Connected to MongoDB Server');
//deleteMany - delete all the occcurences
db.collection('Jokes').deleteMany({joke : 'Sample joke 2'}).then((result) => {
console.log(result.result);
}, (err) => {
cosole.log('Error deleting many. E : ', err)
cosole
/** global: cosole */
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.
});
//deleteOne - deletes only first occurence of all the occurences
db.collection('Jokes').deleteOne({joke : 'Test 1'}).then((result) => {
db.collection('Jokes').findOneAndDelete({joke : 'Test 2'}).then((doc) => {
console.log(doc);
console.log('Error find one and delete. E: ', err);
return
return undefined;
//close the DB
// db.close();